from fastapi import FastAPI
from . import models, database
from .database import engine
from .product_service import router as product_router
from .cart_service import router as cart_router
from .order_service import router as order_router
from .review_service import router as review_router

# 创建数据库表
models.Base.metadata.create_all(bind=engine)

app = FastAPI(title="在线购物系统")

# 注册路由
app.include_router(product_router, prefix="/api", tags=["products"])
app.include_router(cart_router, prefix="/api", tags=["carts"])
app.include_router(order_router, prefix="/api", tags=["orders"])
app.include_router(review_router, prefix="/api", tags=["reviews"])


@app.get("/")
def read_root():
    return {"message": "欢迎使用在线购物系统API"}
